package com.example.jasyptdb.service.impl;

import com.example.jasyptdb.dao.PriceListMapper;
import com.example.jasyptdb.pojo.PriceList;
import com.example.jasyptdb.service.PriceListService;
import com.example.jasyptdb.util.HttpResult;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * TODO
 *
 * @author 江
 * @date 2021/9/13 下午 14:53
 */
@Service
public class PriceListImpl implements PriceListService {

    @Autowired
    PriceListMapper priceListMapper;

    /**
     * 读取数据库
     *
     * @author 江
     * @date 2021/9/13 下午 14:53
     */
    @Override
    public HttpResult selectAllPriceList(int page, int pageSize) {
        List<PriceList> priceLists = null;
        com.github.pagehelper.PageInfo pageInfo1 = null;
        try {
            PageHelper.startPage(page, pageSize);
            priceLists = priceListMapper.selectAllPriceList();
            pageInfo1 = new com.github.pagehelper.PageInfo(priceLists, pageSize);
        } catch (Exception e) {
//            e.printStackTrace();
            return HttpResult.newError("查询失败！");
        }
        return HttpResult.newSuccess().add("data", pageInfo1);
    }


}
